<?php
    ####################################################
    # library import and object instance.              #
    ####################################################
    include_once('./common.php');
    include_once('./app_common.php');


    ####################################################
    # request data($_POST AND $_GET FROM $_REQUEST)    #
    ####################################################
    # REQUEST(get and post variables)
    $req = Request::clean_request($_REQUEST, FALSE);

    # GET(url variables)

    # POST(form variables)

    # Validation(special case validate)

    ####################################################
    # implementation                                   #
    ####################################################

    //*/
    $pagenation_cfg = array(
        'uri'               => "app_list.php",
        'articles_count'    => 20,
        'req_page'          => $req['pagenation'],
        'page_size'         => 6,
        'articles_cnt'      => $db->getcnts($ncrud['table_name']),
        'style'             => Pagenation::$style_default
    );
    $article = $db->gets(
        sprintf("SELECT * FROM `%s` ORDER BY `%s` DESC LIMIT %s, %s ",
            $ncrud['table_name'],
            'fuid',
            $pagenation_cfg['req_page'] * $pagenation_cfg['articles_count'],
            $pagenation_cfg['articles_count']
        )
    );
    $pagenation = Pagenation::out($pagenation_cfg);
    //*/
?>
<?php
    $html->custom_header(TITLE);
    $html->custom_js("{$JS}jquery.1.7.1.min.js");
    $html->custom_js("{$JS}lib.control.js");
    $html->custom_css("{$CSS}basic.css");
?>
<?$html->custom_body();?>
<?=$tmp->tiles_header()?>
<h1>app - list</h1>
        <table width="100%" border="1" cellspacing="0" cellpadding="3" style="border-collapse:collapse">
            <tr>
                <th>
                    fuid
                </th>
                <th>
                    name
                </th>
                <th>
                    name_eng
                </th>
                <th>
                    enable
                </th>
                <th>
                    description
                </th>
                <th>
                    action
                </th>
            </tr>
            <?php if($pagenation_cfg['articles_cnt'] > 0):?>
                <?php foreach($article['res'] as $key=>$val):?>
                    <tr>
                        <td>
                            <?=$val['fuid']?>
                        </td>
                        <td>
                            <?=$val['name']?>
                        </td>
                        <td>
                            <?=$val['name_eng']?>
                        </td>
                        <td>
                            <?=$val['enable']?>
                        </td>
                        <td>
                            <?=$val['description']?>
                        </td>
                        <td>
                            <a href="app_retrieve.php?fuid=<?=$val['fuid']?>">retrieve</a> | <a href="app_update.php?fuid=<?=$val['fuid']?>">update</a> | <a href="app_delete.php?fuid=<?=$val['fuid']?>">delete</a>
                        </td>
                    </tr>
                <?php endforeach;?>
            <?php else:?>
                    <tr>
                        <td align="center" colspan="6">no has data</td>
                    </tr>
            <?php endif;?>
        </table>
        <?=$pagenation?>
    <?=NTool::btn("create", "Mover.href('./app_create.php');");?>
    <span> | </span>
    <?=NTool::btn("back", "Mover.back();");?>
    <?=NTool::btn("index", "Mover.home();");?>
<?=$tmp->tiles_footer()?>
<?php $html->html_footer(); ?>

